package cn.stazxr.controller;

import cn.stazxr.core.RedisTemplate;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author talentestors
 * @version 1.0
 * @since 2025.10.27
 **/
@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TestController {

	private final RedisTemplate redisTemplate;

	@GetMapping("/test")
	public String test() {
		return redisTemplate.setObject("map", List.of("a", "b", "c"));
	}

	@GetMapping("/get/{key}")
	public List<String> get(@PathVariable String key) {
		List<String> map = redisTemplate.getObject("map", new TypeReference<>() {});
		log.info("map: {}", map);
		return map;
	}

}
